<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数据源</title>
</head>
<style>
    *{font-size: 12px;}
    td img {width:80px; height:80px}
    table tr th {border-bottom: 1px solid #aaaaaa; background: #eeeeee; min-width: 85px;}
    table tr td {border-bottom: 1px solid #cccccc; min-width: 85px;}
    .odd{background: #96c6f742}
    .even{background: #fffb7a30}
</style>

<body>
<h1>
    <a th:href="@{/admin/dsAdd}" target="_self">新增</a>
</h1>
<table>
    <thead>
        <tr>
            <th th:text="序号">NO</th>
            <th th:text="ID">dsId</th>
            <th th:text="数据源编码">dsCode</th>
            <th th:text="数据源名称">dsName</th>
            <th th:text="数据源描述">dsDesc</th>
            <th th:text="数据库类型">dsType</th>
            <th th:text="jdbc_url">jdbcUrl</th>
            <th th:text="username">username</th>
            <th th:text="password">password</th>
            <th th:text="driver_class">driverName</th>
            <th th:text="其它参数">dsParams</th>
            <th th:text="状态">state</th>
            <th th:text="创建人">createdBy</th>
            <th th:text="创建时间">created</th>
            <th th:text="更新人">updatedBy</th>
            <th th:text="更新时间">updated</th>
            <th th:text="操作"></th>
        </tr>
    </thead>
    <tbody>
        <tr th:each="ds,iterStat: ${dsList}" th:class="${iterStat.odd}? 'odd':'even'">
            <td th:text="${iterStat.count}">count</td>
            <td th:text="${ds.dsId}">dsId</td>
            <td th:text="${ds.dsCode}">dsCode</td>
            <td th:text="${ds.dsName}">dsName</td>
            <td th:text="${ds.dsDesc}">dsDesc</td>
            <td th:text="${ds.dsType}">dsType</td>
            <td th:text="${ds.jdbcUrl}">jdbcUrl</td>
            <td th:text="${ds.username}">username</td>
            <td th:text="${ds.password}">password</td>
            <td th:text="${ds.driverName}">driverName</td>
            <td th:text="${ds.dsParams}">dsParams</td>
            <td>
                <span th:if="${ds.state} eq 1" th:text="有效">state</span>
                <span th:if="${ds.state} eq 0" th:text="无效">state</span>
            </td>
            <td th:text="${ds.createdBy}">createdBy</td>
            <td th:text="${ds.created}">created</td>
            <td th:text="${ds.updatedBy}">updatedBy</td>
            <td th:text="${ds.updated}">updated</td>
            <td>
                <a href="javascript:void(0);" th:onclick="del([[${ds.dsId}]]);">删除</a>
                <a th:href="@{/admin/dsEdit(dsId = ${ds.dsId})}" target="_self">编辑</a>
            </td>
        </tr>
    </tbody>
</table>
<script type="text/javascript" th:inline="javascript">
    /*<![CDATA[*/
    var xmlHttp;
    var delUrl= /*[[@{/admin/dsDel}]]*/ null;

    var del = function (dsId) {
        if(window.confirm("确认删除？")) {
            xmlHttp = new XMLHttpRequest();
            xmlHttp.onreadystatechange = function(){delCallback();};
            xmlHttp.open("POST", delUrl+"?dsId="+dsId, false);
            xmlHttp.send();
            return true
        } else {
            return false;
        }

    }
    var delCallback = function() {
        if (xmlHttp.readyState==4) {
            if (xmlHttp.status == 200) {
                window.location.reload()  //刷新页面
            }
        }
    }
    /*]]>*/
</script>
</body>
</html>
